package pub.wkq.thread;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

/**
 * @author 王开琦
 */
public class CompletableUtilities {
    //获取并展示 CF 中存储的值
    public static void showr(CompletableFuture<?> completableFuture) {
        try {
            System.out.println(completableFuture.get());
        } catch (InterruptedException | ExecutionException e) {
            throw new RuntimeException(e);
        }
    }

    //针对无值的 CF 操作
    public static void voidr(CompletableFuture<Void> completableFuture) {
        try {
            completableFuture.get();//返回void
        } catch (InterruptedException|ExecutionException e) {
            throw new RuntimeException(e);
        }
    }
}
